

$(function () {
	/**
	*2017-9-24 01:10 新增底部二维码切换_Begin
	*/
	$('#ecodeone').hover(function(){
		
		$('#img_one').show();
		$('#img_tow').hide();
		
	});
	$('#ecodetow').hover(function(){
		$('#img_tow').show();
		$('#img_one').hide();
	});
	
	/**
	*2017-9-24 01:10 新增底部二维码切换_End
	*/
});	

jQuery.easing.jswing=jQuery.easing.swing;jQuery.extend(jQuery.easing,{def:"easeOutQuad",swing:function(e,f,a,h,g){return jQuery.easing[jQuery.easing.def](e,f,a,h,g)},easeInQuad:function(e,f,a,h,g){return h*(f/=g)*f+a},easeOutQuad:function(e,f,a,h,g){return -h*(f/=g)*(f-2)+a},easeInOutQuad:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f+a}return -h/2*((--f)*(f-2)-1)+a},easeInCubic:function(e,f,a,h,g){return h*(f/=g)*f*f+a},easeOutCubic:function(e,f,a,h,g){return h*((f=f/g-1)*f*f+1)+a},easeInOutCubic:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f+a}return h/2*((f-=2)*f*f+2)+a},easeInQuart:function(e,f,a,h,g){return h*(f/=g)*f*f*f+a},easeOutQuart:function(e,f,a,h,g){return -h*((f=f/g-1)*f*f*f-1)+a},easeInOutQuart:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f*f+a}return -h/2*((f-=2)*f*f*f-2)+a},easeInQuint:function(e,f,a,h,g){return h*(f/=g)*f*f*f*f+a},easeOutQuint:function(e,f,a,h,g){return h*((f=f/g-1)*f*f*f*f+1)+a},easeInOutQuint:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f*f*f+a}return h/2*((f-=2)*f*f*f*f+2)+a},easeInSine:function(e,f,a,h,g){return -h*Math.cos(f/g*(Math.PI/2))+h+a},easeOutSine:function(e,f,a,h,g){return h*Math.sin(f/g*(Math.PI/2))+a},easeInOutSine:function(e,f,a,h,g){return -h/2*(Math.cos(Math.PI*f/g)-1)+a},easeInExpo:function(e,f,a,h,g){return(f==0)?a:h*Math.pow(2,10*(f/g-1))+a},easeOutExpo:function(e,f,a,h,g){return(f==g)?a+h:h*(-Math.pow(2,-10*f/g)+1)+a},easeInOutExpo:function(e,f,a,h,g){if(f==0){return a}if(f==g){return a+h}if((f/=g/2)<1){return h/2*Math.pow(2,10*(f-1))+a}return h/2*(-Math.pow(2,-10*--f)+2)+a},easeInCirc:function(e,f,a,h,g){return -h*(Math.sqrt(1-(f/=g)*f)-1)+a},easeOutCirc:function(e,f,a,h,g){return h*Math.sqrt(1-(f=f/g-1)*f)+a},easeInOutCirc:function(e,f,a,h,g){if((f/=g/2)<1){return -h/2*(Math.sqrt(1-f*f)-1)+a}return h/2*(Math.sqrt(1-(f-=2)*f)+1)+a},easeInElastic:function(f,h,e,l,k){var i=1.70158;var j=0;var g=l;if(h==0){return e}if((h/=k)==1){return e+l}if(!j){j=k*0.3}if(g<Math.abs(l)){g=l;var i=j/4}else{var i=j/(2*Math.PI)*Math.asin(l/g)}return -(g*Math.pow(2,10*(h-=1))*Math.sin((h*k-i)*(2*Math.PI)/j))+e},easeOutElastic:function(f,h,e,l,k){var i=1.70158;var j=0;var g=l;if(h==0){return e}if((h/=k)==1){return e+l}if(!j){j=k*0.3}if(g<Math.abs(l)){g=l;var i=j/4}else{var i=j/(2*Math.PI)*Math.asin(l/g)}return g*Math.pow(2,-10*h)*Math.sin((h*k-i)*(2*Math.PI)/j)+l+e},easeInOutElastic:function(f,h,e,l,k){var i=1.70158;var j=0;var g=l;if(h==0){return e}if((h/=k/2)==2){return e+l}if(!j){j=k*(0.3*1.5)}if(g<Math.abs(l)){g=l;var i=j/4}else{var i=j/(2*Math.PI)*Math.asin(l/g)}if(h<1){return -0.5*(g*Math.pow(2,10*(h-=1))*Math.sin((h*k-i)*(2*Math.PI)/j))+e}return g*Math.pow(2,-10*(h-=1))*Math.sin((h*k-i)*(2*Math.PI)/j)*0.5+l+e},easeInBack:function(e,f,a,i,h,g){if(g==undefined){g=1.70158}return i*(f/=h)*f*((g+1)*f-g)+a},easeOutBack:function(e,f,a,i,h,g){if(g==undefined){g=1.70158}return i*((f=f/h-1)*f*((g+1)*f+g)+1)+a},easeInOutBack:function(e,f,a,i,h,g){if(g==undefined){g=1.70158}if((f/=h/2)<1){return i/2*(f*f*(((g*=(1.525))+1)*f-g))+a}return i/2*((f-=2)*f*(((g*=(1.525))+1)*f+g)+2)+a},easeInBounce:function(e,f,a,h,g){return h-jQuery.easing.easeOutBounce(e,g-f,0,h,g)+a},easeOutBounce:function(e,f,a,h,g){if((f/=g)<(1/2.75)){return h*(7.5625*f*f)+a}else{if(f<(2/2.75)){return h*(7.5625*(f-=(1.5/2.75))*f+0.75)+a}else{if(f<(2.5/2.75)){return h*(7.5625*(f-=(2.25/2.75))*f+0.9375)+a}else{return h*(7.5625*(f-=(2.625/2.75))*f+0.984375)+a}}}},easeInOutBounce:function(e,f,a,h,g){if(f<g/2){return jQuery.easing.easeInBounce(e,f*2,0,h,g)*0.5+a}return jQuery.easing.easeOutBounce(e,f*2-g,0,h,g)*0.5+h*0.5+a}});
/**
*三级导航 JS
*/

$(function () {

	var header_nav = false;
	var nav_level = false;
	var nav_level_2 = false;

	var nav_level_3_istrue,nav_level_2_istrue,nav_level_1_istrue = false;

	var nav_is_leave = false;

	$('.apy-all-nav').height($(window).height());
	$('.nav-item-info ul').height($(window).height());
	$('.nav-item-info-level-3 ul').height($(window).height());

	$('.apy-header-all-nav').on('mouseenter',function(){
		header_nav = true;
		
		// $(".apy-header-all-nav").css('background-color',"#0af");
		$(".apy-header-all-nav").addClass('hover');

		if(header_nav || nav_level || nav_level_2){
			$('.all-nav-level1').addClass('active');

			// if(!nav_level_2_istrue){
				$('.all-nav-level1').css({'left':"-200px","z-index":"300"});
				$('.all-nav-level1').animate({
					"left":"0"
				},{
                	easing:"easeOutQuad"//缓动
            	},800);	
			// }else{nav_level_2_istrue = true; }

			$('.apy-all-nav').css('z-index',998);

		}

	});

	
	$('.all-nav-level1').on('mouseenter',function(){
		nav_level = true;
		if(header_nav || nav_level || nav_level_2){
			$('.all-nav-level1').addClass('active');

			$('.apy-all-nav').css('z-index',998);
		}
	});

	$('.apy-header-all-nav').on('mouseleave',function(){
		header_nav = false;

		if(!header_nav && !nav_level ){
			$('.all-nav-level1').removeClass('active');

			$('.apy-all-nav').css('z-index',-998);
		}

	});

	$('.all-nav-level1').on('mouseleave',function(){
		nav_level = false;

		$('.all-nav-level1').removeClass('active');
		$('.apy-all-nav').css('z-index',-998);

		$('.nav-item-info').on('mouseenter',function(){
				$('.all-nav-level1').addClass('active');
				$('.apy-all-nav').css('z-index',998);
				$(this).show();

		});

		$('.nav-item-info').on('mouseleave',function(){
				$(this).hide();
		});

	});

	$(".nav-item-info li").on('mouseenter',function(){
		
		var nav_level_2_key  = $(this).data('key');
		var currentClass = $(this).parent().attr('class');

		if($(".nav-item-info-level-3 ul."+nav_level_2_key+"").length == 1){
			$('.nav-item-info-level-3').show();
		}else{
			$(this).css('background-color','transparent');
			$('[data-key="'+currentClass+'"]').find('a').parent().addClass('apy-current-li');
			$('[data-key="'+currentClass+'"]').find('a').addClass('apy-current-a');
			return false;
		}

		$(".nav-item-info-level-3 ul").hide();

		if(!nav_level_3_istrue){

			$(".nav-item-info-level-3 ul."+nav_level_2_key+"").css({"z-index":"100","display":"block"});
			$(".nav-item-info-level-3").css({'left':"200px","z-index":"100","display":"block"});
			// $(".nav-item-info-level-3 ul."+nav_level_2_key+"").animate({
			$(".nav-item-info-level-3").animate({
				"left":"400px",
				// "z-index":"2000"
			},{
                easing:"easeOutQuad"//缓动
            },800);
			nav_level_3_istrue = true;	
		}else{$(".nav-item-info-level-3 ul."+nav_level_2_key+"").show();}

		// var currentClass = $(this).parent().attr('class');
		// $('.nav-level1 li[data-key="xxx"]').css('color',"red");
		$('[data-key="'+currentClass+'"]').find('a').addClass('apy-current-a');
		$('[data-key="'+currentClass+'"]').find('a').addClass('apy-current-a');
		$('[data-key="'+currentClass+'"]').find('a').parent().addClass('apy-current-li');

	});

	$(".nav-item-info li").on('mouseleave',function(){

			$(".nav-item-info-level-3").hide();

	});

	$('.nav-item-info').on('mouseleave',function(){
			nav_level_3_istrue = false;	

		$('.all-nav-level1').on('mouseleave',function(){
				$(this).removeClass('active');
		});

		$('.nav-item-info-level-3').on('mouseenter',function(){
			$(this).show();
		});

		$('.all-nav-level1').on('mouseenter',function(){
			$('.nav-level1 ul li a').removeClass('apy-current-a');
			$('.nav-level1 ul li').removeClass('apy-current-li');
		});

	});

	$(".nav-level1 li").on('mouseenter',function(){

		var nav_level_li_key = $(this).data('key');
		$('.nav-item-info').show();
		// $(".nav-item-info ul").hide();

		if($(".nav-item-info ul."+nav_level_li_key+"").length == 1){
			
				$(".nav-item-info ul").hide();

			if(!nav_level_2_istrue){

				$(".nav-item-info").css({'left':"0px","display":"block","z-index":"200"});
				$(".nav-item-info ul."+nav_level_li_key+"").css({'left':"0px","display":"block","z-index":"300"});
				$(".nav-item-info").stop().animate({
					"left":"200px",
					"display":"block",
					// "z-index":"400"
				},{
	                easing:"easeOutQuad"//缓动
	            },800);
				nav_level_2_istrue=true;
				console.log($('.nav-item-info').css('left'));
			}else{$(".nav-item-info ul."+nav_level_li_key+"").show();}
		}else{

				// if($(".nav-item-info-level-3").css('display') == 'none' ){

					$(".nav-item-info").css({'left':"200px","display":"block","z-index":"200"});
					// $(".nav-item-info-level-3").css({'left':"400px","display":"block","z-index":"200"});
					$('.nav-item-info').stop().animate({
						"left":"0px"
					},{
						easing:"easeOutQuad",
					},800);

					// $(".nav-item-info-level-3").stop().animate({
					// 	"left":"200px"
					// },{
					// easing:"easeOutQuad"},1600);

					nav_level_2_istrue=false;
				// }
		}


        if($(".nav-item-info-level-3").css('display') !== 'none' &&  $(".nav-item-info").css('display') !== 'none' && $(".nav-item-info ul."+nav_level_li_key+"").length ==0 ) {
					$(".nav-item-info").css({'left':"200px","display":"block","z-index":"200"});
					$(".nav-item-info-level-3").css({'left':"400px","display":"none","z-index":"200"});
					$('.nav-item-info').stop().animate({
						"left":"0px"
					},{
						easing:"easeOutQuad",
					},800);

					$(".nav-item-info-level-3").stop().animate({
						"left":"200px"
					},{
					easing:"easeOutQuad"},1600);

					nav_level_2_istrue=false;
        }

		// $(".nav-item-info div."+nav_level_li_key+"").show();

	})

	$(".nav-level1 li").on('mouseleave',function(){
		$('.nav-item-info').hide();
	})

	$('.nav-item-info').on('mouseleave',function(){
		// $(this).hide();

		$('.all-nav-level1 li').on('mouseenter',function(){

			if($(".nav-item-info-level-3").css('display') !== 'none' ){
				$(".nav-item-info-level-3").css({'left':"400px","display":"block","z-index":"200"});
				$('.nav-item-info-level-3').stop().animate({
					"left":"200px"
				},{
					easing:"easeOutQuad",
				},800);
			}
		});

	});

	$('.nav-item-info-level-3').on('mouseenter',function(){
			$(".nav-item-info").show();

	});

	$('.nav-item-info-level-3 li').on('mouseenter',function(){
			$(".nav-item-info").show();

		var currentLevel2Class = $(this).parent().attr('class');
		// $('.nav-level1 li[data-key="xxx"]').css('color',"red");
		$('[data-key="'+currentLevel2Class+'"]').find('a').addClass('apy-current-a');		
		$('[data-key="'+currentLevel2Class+'"]').find('a').parent().addClass('apy-current-li');		

	});

	$('.nav-item-info-level-3').on('mouseleave',function(){
		var that= this;
		$('.nav-item-info').on('mouseenter',function(){
			// $(that).hide();
			$(this).show();

			$('.nav-item-info ul li a').removeClass('apy-current-a');
			$('.nav-item-info ul li').removeClass('apy-current-li');
		});

	});

	var el = window.document.body;
	window.document.body.onmouseover = function(event){
	    el = event.target;

		if($(".nav-item-info").css('display') == 'none' && $(".all-nav-level1").css('display') == 'none' && $(".nav-item-info-level-3").css('display') == 'none' ){
			$(".apy-header-all-nav").removeClass('hover');
		}

	}

	$(document).mousemove(function(e){
	      e=e||window.event;
		    var scrollX=document.documentElement.scrollLeft||document.body.scrollLeft;//分别兼容ie和chrome
		    var scrollY=document.documentElement.scrollTop||document.body.scrollTop;
		    var x=e.pageX||(e.clientX+scrollX);//兼容火狐和其他浏览器
		    var y=e.pageY||(e.clientY+scrollY);

		   if(x >600){
		   			$('.all-nav-level1').removeClass('active');
		   			$('.nav-item-info-level-3').hide();
		   			$('.nav-item-info').hide();
		   			$('.apy-all-nav').css('z-index',-988);

		   			$('.nav-item-info ul li a').removeClass('apy-current-a');
		   			$('.nav-level1 ul li a').removeClass('apy-current-a');
		   			$('.nav-level1 ul li').removeClass('apy-current-li');
		   			$('.nav-level1 ul li').removeClass('apy-current-li');

		   }

		   if(x > 50 && y < 50){

		   			$('.all-nav-level1').removeClass('active');
		   			$('.nav-item-info-level-3').hide();
		   			$('.nav-item-info').hide();
		   			$('.apy-all-nav').css('z-index',-988);


		   			$('.nav-item-info ul li a').removeClass('apy-current-a');
		   			$('.nav-level1 ul li a').removeClass('apy-current-a');
		   			$('.nav-level1 ul li').removeClass('apy-current-li');
		   			$('.nav-level1 ul li').removeClass('apy-current-li');
		   }

		   if(x > 400  &&  $(".nav-item-info").css('display') == 'none'){

		   			$('.all-nav-level1').removeClass('active');
		   			$('.nav-item-info-level-3').hide();
		   			$('.nav-item-info').hide();
		   			$('.apy-all-nav').css('z-index',-988);

		   }

		   if(x < 200 && $(".nav-item-info").css('display') == 'none'){
		   			// $('.all-nav-level1').removeClass('active');
		   			$('.nav-item-info-level-3').hide();
		   			$('.nav-item-info').hide();

		   				nav_level_3_istrue = false;
		   				nav_level_2_istrue = false;
		   }

		   if(x >200 && x <400 && $(el).hasClass('activity')){
		   		$('.nav-item-info-level-3').hide();
		   }

	});

	window.onmousewheel=function(e){

		if($(el).parents().hasClass('apy-all-nav')){
			return false;
		}
	};  
});	

/**
*头部默认导航选中
*/
$(function(){

	var currentControllerName = window.location.pathname.split('/');
	var currentControllerNameFirst = window.location.pathname.split('/')[1];
	var currentControllerNameSeconed = window.location.pathname.split('/')[2];

	console.log(currentControllerName);
	// switch
	if(currentControllerNameFirst == 'act' && currentControllerNameSeconed ==''){
		$(".header-nav li.header-nav-li:eq(0)").addClass('apy-header-nav-li-active');
	}else if(currentControllerNameFirst == 'server' 
		|| currentControllerNameFirst == 'loadbalance' 
		|| currentControllerNameFirst == 'lease'
		|| currentControllerNameFirst == 'idc'
		|| currentControllerNameFirst == 'host'
		|| currentControllerNameFirst == 'domain'
		|| currentControllerNameFirst == 'ssl'
		|| currentControllerNameFirst == 'icp'
		|| currentControllerNameFirst == 'monitor'
		|| currentControllerNameFirst == 'cloudApp'){
		console.log(currentControllerNameSeconed);
		if(currentControllerNameSeconed == 'price'){
			$(".header-nav li.header-nav-li:eq(4)").addClass('apy-header-nav-li-active');
		}else{
			$(".header-nav li.header-nav-li:eq(1)").addClass('apy-header-nav-li-active');
		}
	}else if(currentControllerNameFirst == 'trustcenter' 
		|| currentControllerNameFirst == 'datacenter' 
		|| currentControllerNameFirst == 'support'
	){
		$(".header-nav li.header-nav-li:eq(5)").addClass('apy-header-nav-li-active');
	}else if(currentControllerNameFirst == 'solutions'){
		$(".header-nav li.header-nav-li:eq(2)").addClass('apy-header-nav-li-active');
	}else if(currentControllerNameFirst == 'help'){
		$(".header-nav li.header-nav-li:eq(6)").addClass('apy-header-nav-li-active');
	}else if(currentControllerNameFirst == 'act' && currentControllerNameSeconed == 'cps')
		{$(".header-nav li.header-nav-li:eq(7)").addClass('apy-header-nav-li-active');}
	else if(currentControllerNameFirst == 'about' || currentControllerNameFirst == 'news')
		{$(".header-nav li.header-nav-li:eq(8)").addClass('apy-header-nav-li-active');}
})

/**
*解决导航高度问题
*/
$(function(){

	$(window).on('resize',function(){

		console.log($(window).height());

		$('.apy-all-nav').height($(window).height());
		$('.nav-item-info ul').height($(window).height());
		$('.nav-item-info-level-3 ul').height($(window).height());
	});
})

/**
*搜索
*/
$(function(){

	$(".top-nav.header-main").on('mouseenter',function(){

		$(".apy-search-help").css('background-color','rgba(99,99,99,.5)');
		// $(".apy-search-help").css('background-color','#2f3544');
	})

	$(".top-nav.header-main").on('mouseleave',function(){

		$(".apy-search-help").css('background-color','rgba(238,238,224, 0.15)');
		// $(".apy-search-help").css('background-color','rgba(128,128,128,.3)');
	})

	$(".apy-search-help").on('mouseenter',function(){
		$(this).find('i').css('color',"#0af");

		$(this).find('input').stop().animate({
			"width":"300px",
		},{
			easing:"easeOutQuad",
		},250);

	})

	$(".apy-search-help").on('mouseleave',function(){
		$(this).css('border-color','rgba(43,48,56,.6)');
		$(this).css('outline','none');
		$(this).find('i').css('color',"#fff");
		$(this).find('input').stop().animate({
			"width":"200px"
		},{
			easing:"easeOutQuad",
		},250);

	});

	$(".apy-search-help i").on('click',function(){

		window.location.href = '/help/search?k=' + $(".apy-search-help input").val();
	})

	$(".apy-search-help input").keyup(function(event){
		 if(event.keyCode ==13){
		 	window.location.href = '/help/search?k=' + $(".apy-search-help input").val();
		 }
	});

	$(".apy-china").on('mouseenter',function(){
		$(this).find('i').css('color',"#0af");
		$(this).find('a').css('color',"#0af");
	});

	$(".apy-china").on('mouseleave',function(){
		$(this).find('i').css('color',"#fff");
		$(this).find('a').css('color',"#fff");
	})

	$('.apy-language-switch li:eq(1)').on('mouseenter',function(){
		$(this).css('color',"#0af");
	});

	$('.apy-language-switch li:eq(1)').on('mouseleave',function(){
		$(this).css('color',"#333");
	});

	$(".apy-develop-warn").on('click',function(){
		NY.warn('正在开发中...');
	});
});